package cn.sh.library.gmwx.sparql.impl;

import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import cn.sh.library.gmwx.annotation.GraphDefine;
import cn.sh.library.gmwx.base.Constant;
import cn.sh.library.gmwx.dao.impl.BaseDaoImpl;
import cn.sh.library.gmwx.sparql.BaseinfoSparql;
import cn.sh.library.gmwx.sparql.RdfQuery;
import cn.sh.library.gmwx.sparql.SparqlExecution;
import cn.sh.library.gmwx.utils.RDFUtils;

@Repository
@GraphDefine(name = Constant.GRAPH_BASEINFO)
public class BaseinfoSparqlImpl extends BaseDaoImpl implements BaseinfoSparql {
    @Override
    public List<Map<String, String>> getLabels(String type) {
        return RDFUtils.transformListMap(SparqlExecution.vQuery(graph, RdfQuery.RDF_QUERY_VOCAB_LIST.toString(type), "uri", "label", "label_en"));
    }

    @Override
    public List<Map<String, String>> getTriples(String graph, String uri) {
        return RDFUtils.transformListMap(SparqlExecution.vQuery(getModel(graph), RdfQuery.RDF_QUERY_TRIPLES.toString(uri), "s", "p", "o"));
    }
}
